﻿Imports System
Public Class OptionsForm
    Dim units As Double

    Private Sub OptionsForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If My.Settings.Units = MeterRadioButton.Text Then
            MeterRadioButton.Checked = True

        ElseIf My.Settings.Units = InchesRadioButton.Text Then
            InchesRadioButton.Checked = True

        ElseIf My.Settings.Units = CMRadioButton.Text Then
            CMRadioButton.Checked = True
        ElseIf My.Settings.Units = MMRadioButton.Text Then
            MMRadioButton.Checked = True
        Else
            MeterRadioButton.Checked = False
            InchesRadioButton.Checked = False
            MMRadioButton.Checked = False
            CMRadioButton.Checked = False
        End If
        DecimalNumericUpDown.Value = My.Settings.DecimalPlace
        HeadingTextBox.Text = My.Settings.HeadingText

    End Sub

    Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApply.Click
        If MeterRadioButton.Checked.Equals(True) Then
            My.Settings.Units = MeterRadioButton.Text
            My.Settings.UnitMultiplier = 1
        ElseIf InchesRadioButton.Checked.Equals(True) Then
            My.Settings.Units = InchesRadioButton.Text
            My.Settings.UnitMultiplier = 39.3700787
        ElseIf CMRadioButton.Checked.Equals(True) Then
            My.Settings.Units = CMRadioButton.Text
            My.Settings.UnitMultiplier = 100
        ElseIf MMRadioButton.Checked.Equals(True) Then
            My.Settings.Units = MMRadioButton.Text
            My.Settings.UnitMultiplier = 1000
        End If

        My.Settings.DecimalPlace = DecimalNumericUpDown.Value
        My.Settings.HeadingText = HeadingTextBox.Text

        My.Settings.Save()
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If MeterRadioButton.Checked.Equals(True) Then
            My.Settings.Units = MeterRadioButton.Text
            My.Settings.UnitMultiplier = 1
            My.Settings.AreaMultiplier = 1
        ElseIf InchesRadioButton.Checked.Equals(True) Then
            My.Settings.Units = InchesRadioButton.Text
            My.Settings.UnitMultiplier = 39.3700787
            My.Settings.AreaMultiplier = 1550.0031
        ElseIf CMRadioButton.Checked.Equals(True) Then
            My.Settings.Units = CMRadioButton.Text
            My.Settings.UnitMultiplier = 100
            My.Settings.AreaMultiplier = 10000
        ElseIf MMRadioButton.Checked.Equals(True) Then
            My.Settings.Units = MMRadioButton.Text
            My.Settings.UnitMultiplier = 1000
            My.Settings.AreaMultiplier = 1000000
        End If

        My.Settings.DecimalPlace = DecimalNumericUpDown.Value
        My.Settings.Save()
        Me.Close()
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

End Class